package com.kfyty.loveqq.framework.boot.web.example.config;

import cn.dev33.satoken.dao.SaTokenDao;
import cn.dev33.satoken.dao.SaTokenDaoForRedisson;
import cn.dev33.satoken.loveqq.boot.filter.SaRequestFilter;
import cn.dev33.satoken.loveqq.boot.interceptor.SaInterceptor;
import com.kfyty.loveqq.framework.core.autoconfig.annotation.Bean;
import com.kfyty.loveqq.framework.core.autoconfig.annotation.Component;
import org.redisson.api.RedissonClient;

/**
 * 描述: sa-token 配置
 *
 * @author kfyty725
 * @date 2024/8/2 17:07
 * @email kfyty725@hotmail.com
 */
@Component
public class SaTokenConfiguration {
    /**
     * 开启注解检查
     */
    @Bean
    public SaInterceptor saInterceptor() {
        return new SaInterceptor();
    }

    /**
     * 拦截器
     */
    @Bean
    public SaRequestFilter saRequestFilter() {
        return new SaRequestFilter()
                .addInclude("/**")
                .addExclude("/ignored");
    }

    /**
     * redis dao 集成
     */
    @Bean
    public SaTokenDao saTokenDao(RedissonClient redisson) {
        return new SaTokenDaoForRedisson(redisson);
    }
}
